package com.terrace.db.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.terrace.db.constant.DBType;
import com.terrace.db.system.dao.LogDao;
import com.terrace.db.system.mapper.entity.Log;
import com.terrace.db.system.mapper.entity.LogWithDetails;
import com.terrace.db.system.service.LogService;
import com.terrace.core.mybatis.entity.Pagination;
import com.terrace.core.mybatis.plugin.pagination.PaginationHelper;
import com.terrace.core.spring.datasource.annotation.DataSource;

@Service
@Transactional
@DataSource(name = DBType.ADMIN)
public class LogServiceImpl implements LogService {
	
	@Autowired
	private LogDao logDao;

	@Override
	public int saveLogSelective(LogWithDetails log) {
		return logDao.saveLogSelective(log);
	}

	@Override
	public LogWithDetails selectLogDetailsById(int logId) {
		return logDao.selectLogDetailsById(logId);
	}

	@Override
	public Pagination<Log> selectLogsForPagination(Pagination<Log> pagination, Log log) {
		PaginationHelper.prepare(pagination);
		return PaginationHelper.execute(logDao.selectLogsForPagination(log));
	}

}
